package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.WmNewsStatisticsDto;
import com.heima.wemedia.receive.page.ResponseResult;
import com.heima.wemedia.service.WmNewsStatisticsService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Slf4j
@RestController
@RequestMapping("/api/v1/statistics")
public class WmNewsStatisticsController {
    @Autowired
    private WmNewsStatisticsService wmNewsStatisticsService;
    @GetMapping("newsDimension")
    public ResponseResult newsDimension(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate,@DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate){
        log.info("传入图文统计参数为：开始日期{},结束日期{}",beginDate,endDate);
        return wmNewsStatisticsService.newsDimension(beginDate,endDate);
    }

    @GetMapping("newsPage")
    public ResponseResult newsPage(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate,
                                   @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,
                                   @RequestParam Short page,
                                   @RequestParam Short size){
        log.info("传入图文统计列表参数为：beginDate = {},endDate = {}，page = {} ,size = {}",beginDate,endDate,page,size);
        return wmNewsStatisticsService.newsPage(beginDate,endDate,page,size);
    }
}
